import * as types from './mutation-types'

export default {
  [types.INC_TOTAL_TIME] (state, time) {
    // 数值前面加~~，相当于截取数值整数部分
    state.totalTime = state.totalTime + ~~time
  },
  [types.DEC_TOTAL_TIME] (state, time) {
    state.totalTime = state.totalTime - time
  },
  [types.ADD_TASK] (state, plan) {
    // 设置默认值，未来我们可以做登入直接读取昵称和头像
    const avatar = '../../static/2113467415.jpg';
    state.list.push(
      Object.assign({ name: '二哲', avatar: avatar }, plan)
    )
    // plan.name = '张三'
    // plan.avatar = '../../static/2113467415.jpg'
    // state.list.push(plan)
  },
  [types.DEL_TASK] (state, idx) {
    state.list.splice(idx, 1);
  }
}
